package com.neuede.util;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;

public class BaseDao {
	
	       public static final String DRIVER="com.mysql.cj.jdbc.Driver";
	   	   public static final String URL="jdbc:mysql://localhost:3306/test0715";
			public static final String  USERNAME="root";
			public static final String PASSWORD="root";
	      private static Connection connection;
	      
			static {
				try {
					Class.forName(DRIVER);
					connection=DriverManager.getConnection(URL, USERNAME, PASSWORD);
					
					
				}catch(Exception e) {
					e.printStackTrace();
				}
			}
			
			public static Connection getConnection() {
				return connection;
			}
			
			public static void close(Statement ptmt) {
				try {
					if(ptmt!=null) {
						ptmt.close();
					}
				}catch(Exception e) {
					
				}
			}
			
			public static void close(ResultSet rs,Statement ptmt) {
				try{
					if(rs!=null) {
						rs.close();
					}
					if(ptmt!=null) {
						ptmt.close();
					}
				}catch(Exception e) {
					
				}
			}
			
			public static void close() {
				try {
					if(connection !=null) {
						connection.close();
					}
				}catch(Exception e) {
					
				}
			}
}
